/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;
import java.util.Set;

/**
* @website https://el-admin.vip
* @description /
* @author whj
* @date 2021-01-16
**/
@Entity
@Getter
@Setter
@Table(name="image")
public class Image implements Serializable {

    @Id
    @Column(name = "image_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "imageId")
    private Long imageId;

    @ManyToMany
    @JoinTable(name = "task_image",
            joinColumns = {@JoinColumn(name = "image_id",referencedColumnName = "image_id")},
            inverseJoinColumns = {@JoinColumn(name = "mark_task_id",referencedColumnName = "mark_task_id")})
    @ApiModelProperty(value = "用户任务")
    private List<TaskMark> taskMarks;

    @Column(name = "image_name")
    @ApiModelProperty(value = "图片名(带后缀名)")
    private String imageName;

    @Column(name = "iamge_path")
    @ApiModelProperty(value = "图片绝对路径")
    private String iamgePath;

    @Column(name = "num_box")
    @ApiModelProperty(value = "标注json的框数量(初始为0)")
    private Long numBox;

    @Column(name = "result_path")
    @ApiModelProperty(value = "标注结果json路径")
    private String resultPath="";

    @Column(name = "status")
    @ApiModelProperty(value = "0未标注/1标注部分/2等待审核/3审核通过/4审核不通过")
    private Long status;

    @Column(name = "upload_json_time")
    @ApiModelProperty(value = "上传标注的时间")
    private Timestamp uploadJsonTime;

    @Column(name = "height")
    @ApiModelProperty(value = "图片高度")
    private Long height;

    @Column(name = "size")
    @ApiModelProperty(value = "图片大小")
    private Long size;

    @Column(name = "width")
    @ApiModelProperty(value = "图片宽度")
    private Long width;

    @OneToOne
    @JoinColumn(name = "marked_json_id")
    @ApiModelProperty(value = "markedJson的ID")
    private MarkedJson markedJson;

    public void copy(Image source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    @Override
    public String toString() {
        return "Image{" +
                "imageId=" + imageId +
//                ", taskMarks=" + taskMarks +
                ", imageName='" + imageName + '\'' +
                ", iamgePath='" + iamgePath + '\'' +
                ", numBox=" + numBox +
                ", resultPath='" + resultPath + '\'' +
                ", status=" + status +
                ", uploadJsonTime=" + uploadJsonTime +
                ", height=" + height +
                ", size=" + size +
                ", width=" + width +
                ", markedJson=" + markedJson +
                '}';
    }
}